{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### 过渡矩阵P及基变换\n",
    "对于n维向量X，在基$(e_1,e_2,...,e_n)下的坐标为(x_1,x_2,...,x_n)$，则存在n阶满秩过渡矩阵P,使得向量X在该空间另一组基\n",
    "$(e_1^{'},e_2^{'},...,e_n^{'})$的坐标为$(x_1^{'},x_2^{'},...,x_n^{'})$，且满足：\n",
    "<br>$P(x_1,x_2,...,x_n)^T=(x_1^{'},x_2^{'},...,x_n^{'})^T$，其中P为$(e_1^{'},e_2^{'},...,e_n^{'})$在\n",
    "$(e_1,e_2,...,e_n)$下的坐标。\n",
    "\n",
    "过渡矩阵解决的是同个向量在不同基下的坐标转换，而初等行列变换可视为在同个基下的向量移动，过渡矩阵是满秩的。\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "### 等价矩阵\n",
    "假设有两个$\\ m\\times n$的矩阵，记作A和B。当且仅当存在两个可逆的方块矩阵： $\\displaystyle m\\times m$的矩阵P以及$\\displaystyle n\\times n$的矩阵Q，使得：\n",
    "$B=PAQ$此时，两者等价，记作：$A\\sim B$\n",
    "很容易理解，等价矩阵的秩相等。等价矩阵具有以下三个性质：\n",
    "\n",
    "反身性：$A\\sim A$\n",
    "\n",
    "对称性：若$A\\sim B$，则$B\\sim A$\n",
    "\n",
    "传递性：若$A\\sim B$，$B\\sim C$，则$A\\sim C$\n",
    "\n",
    "\n",
    "\n",
    "### 等价矩阵的充分必要条件\n",
    "A,B为同型矩阵，A,B等价的充要条件为：$A\\sim B\\iff rank(A)=rank(B)$\n",
    "\n",
    "### 行等价与列等价\n",
    "AQ可以看作对A进行了初等列变换，所以上面的等价关系也可以称为列等价，可以记作：$A\\stackrel{c}{\\sim}AQ$\n",
    "PA可以看作对A进行了初等行变换，所以上面的等价关系也可以称为行等价，可以记作：$A\\stackrel{r}{\\sim}PA$\n",
    "从几何上来说，等价矩阵函数可以看做在基1下的位置1，移动至基2下的位置2.具体分为标准化基移动及个性化基三步骤。列等价可以看做移动机个性化基2步，而行等价可以看成标准化基及移动2步。\n",
    "\n",
    "### 相似矩阵\n",
    "设A,B都是n阶矩阵，若有可逆矩阵P，使：$P^{-1}AP=B$则称P为相似变换矩阵，称B是A的相似矩阵，记作：$A\\simeq B$显然，相似矩阵必然也是等价矩阵。\n",
    "相似矩阵与等价矩阵相比，可以看做是等价矩阵的特殊情况，即基2与基1是一样的。\n",
    "### 相似矩阵的特性\n",
    "假定N阶方阵A，B是相似矩阵。则有:\n",
    "\n",
    "$A\\simeq B \\iff A^T\\simeq B^T$\n",
    "\n",
    "$A\\simeq B \\iff A^{-1}\\simeq B^{-1}$\n",
    "\n",
    "$A\\simeq B \\iff A^{k}\\simeq B^{k},k\\in N^+$\n",
    "\n",
    "\n",
    "### 特征向量与特征值\n",
    "设A是n阶矩阵，如果数$\\lambda$和n维非零列向量$\\boldsymbol{x}$使关系式：$A\\boldsymbol{x}=\\lambda\\boldsymbol{x}$\n",
    "成立，那么这样的数$\\lambda$称为矩阵A的特征值，非零向量$\\boldsymbol{x}$称为A的对应于$\\lambda的$特征向量。\n",
    "\n",
    "### 相似矩阵具有相同特征值和迹\n",
    "$A\\simeq B\\implies |A|=|B|$\n",
    "并且假设：A的特征值=B的特征值=$\\{\\lambda_{1},\\lambda_{2},\\cdots,\\lambda_{n}\\}$\n",
    "那么：$|A|=|B|=\\lambda_{1}\\lambda_{2}\\cdots\\lambda_{n}$\n",
    "\n",
    "假设有$n\\times n$的矩阵：\n",
    "$A=(a_{ij})$并且：\n",
    "A的特征值=$\\{\\lambda_{1},\\lambda_{2},\\cdots,\\lambda_{n}\\}$\n",
    "对角线之和等于特征值之和：\n",
    "$a_{11}+a_{22}+\\cdots+a_{nn}=\\lambda_{1}+\\lambda_{2}+\\cdots+\\lambda_{n}\\\\$\n",
    "即矩阵的迹是其特征值的总和。\n",
    "\n",
    "### 特征值的性质\n",
    "假定N阶方阵A有特征值$\\lambda $。则有:\n",
    "\n",
    "$Ax=\\lambda x \\iff A^Tx=\\lambda x$\n",
    "\n",
    "$Ax=\\lambda x \\iff A^{-1}x=\\frac{1}{\\lambda}x$\n",
    "\n",
    "$Ax=\\lambda x \\iff (mA-nI)x=(m\\lambda-n) x;m,n\\in N^+$,I是N阶单位矩阵\n",
    "\n",
    "\n",
    "### 特征空间\n",
    "\n",
    "一个$\\color{Salmon}{特征空间}$是具有相同特征值的特征向量与一个同维数的零向量的集合。\n",
    "线性变换A中以$\\lambda$为特征值的特征空间是某向量空间V的子空间，记作：\n",
    "$\\displaystyle\\textstyle E_{\\lambda}=\\{u\\in V\\mid Au=\\lambda u\\}$\n",
    "\n",
    "同特征向量只能有1个特征值，但同个特征值却可能对应多个特征向量。所有特征向量和同维度的0向量构成一个特征空间。\n",
    "\n",
    "### 对角化\n",
    "若A为n阶矩阵，有n个线性无关的特征向量：\n",
    "$\\boldsymbol{p_1},\\boldsymbol{p_2},\\cdots,\\boldsymbol{p_n}$\n",
    "对应的n个特征值为：\n",
    "$\\boldsymbol{\\lambda_1},\\boldsymbol{\\lambda_2},\\cdots,\\boldsymbol{\\lambda_n}$\n",
    "由特征向量组成的特征矩阵P表示为：\n",
    "$P=(\\boldsymbol{p_1},\\boldsymbol{p_2},\\cdots,\\boldsymbol{p_n})$\n",
    "则有：$P^{-1}AP=\\Lambda$。即：$A\\simeq\\Lambda$，其中$\\Lambda=diag(\\lambda_{1},\\lambda_{2},\\cdots,\\lambda_{n})$\n",
    "\n",
    "\n",
    "### 对角化的充分必要条件\n",
    "对于N阶方阵A可以对角化成$\\Lambda=diag(\\lambda_{1},\\lambda_{2},\\cdots,\\lambda_{n})$的充分必要条件是矩阵A有有n个线性无关的特征向量。\n",
    "若A有N个不同特征值，则A必有N个线性无关的特征向量，换句话说，A必能对角化。但反之不能成立。\n",
    "\n",
    "\n",
    "\n",
    "### 标准正交基\n",
    "设n维向量$\\boldsymbol{\\epsilon_1},\\cdots,\\boldsymbol{\\epsilon_r}$是向量空间$V(V\\subset \\mathbb{R^n})$的一个基，且两两正交：\n",
    "$\\boldsymbol{\\epsilon_i}\\cdot\\boldsymbol{\\epsilon_j}=0$\n",
    "模长为1:\n",
    "$||\\boldsymbol{\\epsilon_1}||=||\\boldsymbol{\\epsilon_2}||=\\cdots=||\\boldsymbol{\\epsilon_r}||=1$\n",
    "那么，$\\boldsymbol{\\epsilon_1},\\cdots,\\boldsymbol{\\epsilon_r}$是$V(V\\subset \\mathbb{R^n})$的标准正交基。\n",
    "\n",
    "### 标准正交基下的坐标\n",
    "\n",
    "若$\\boldsymbol{\\epsilon_1},\\cdots,\\boldsymbol{\\epsilon_r}$是V的一个标准正交基，那么对于V中任一向量$\\boldsymbol{a}$有：\n",
    "\n",
    "$a_i=\\boldsymbol{\\epsilon_i}^T\\boldsymbol{a}=\\boldsymbol{a}\\cdot \\boldsymbol{\\epsilon_i}$\n",
    "\n",
    "其中，$a_i$为$\\boldsymbol{a}在\\boldsymbol{\\epsilon_i}$上的分量。\n",
    "\n",
    "### 正交矩阵\n",
    "如果n阶矩阵A满足：\n",
    "$A^TA=I,即A^T=A^{-1}$\n",
    "那么称A为正交矩阵，简称正交矩阵。\n",
    "正交矩阵可以视为标准正交基之间的过渡矩阵。\n",
    "旋转矩阵是正交矩阵的一种特殊情形。\n",
    "\n",
    "### 正交矩阵的性质\n",
    "假定N阶方阵A，B是正交矩阵。则有:\n",
    "\n",
    "$A^TA=I \\iff (A^{-1})^T(A^{-1})=I$\n",
    "\n",
    "$A^TA=I \\iff (A^{n})^T(A^{n})=I,n\\in N^+$\n",
    "\n",
    "$A^TA=I,B^TB=I \\implies (AB)^T(AB)=I$\n",
    "\n",
    "$A^TA=I \\implies det(A)=\\pm1$\n",
    "\n",
    "### 对角正交化的充分必要条件\n",
    "* 对角化：以特征向量为基\n",
    "* 正交化：以单位正交向量为基\n",
    "\n",
    "既对角又正交的矩阵称对角正交矩阵。\n",
    "$A可以对角正交化 \\iff A^T=A$\n",
    "\n",
    "### 二次型\n",
    "把含有n个变量的二次齐次函数：\n",
    "$\\begin{aligned}f(x_1,x_2,\\cdots,x_n)&=a_{11}x_1^2+a_{22}x_2^2+\\cdots+a_{nn}x_n^2+2a_{12}x_1x_2+2a_{13}x_1x_3+\\cdots+2a_{n-1,n}x_{n-1}x_n\\end{aligned}$\n",
    "\n",
    "$f=\\begin{pmatrix}x_1&x_2&\\cdots&x_n\\end{pmatrix}\\begin{bmatrix}a_{11}&a_{12}&\\cdots&a_{1n}\\\\a_{12}&a_{22}&\\cdots&a_{2n}\\\\\\vdots&\\vdots&\\ddots&\\vdots\\\\a_{1n}&a_{2n}&\\cdots&a_{nn}\\end{bmatrix}\\begin{pmatrix}x_1\\\\x_2\\\\\\vdots\\\\x_n\\end{pmatrix}$称为二次型。\n",
    "任给一个二次型就能唯一的确定一个对称矩阵，反之，任给一个对称矩阵，也可唯一的确定一个二次型。因此，我们把对称矩阵A叫做二次型f的矩阵。对称矩阵A的秩就叫做二次型的秩。\n",
    "简单来说，实对称矩阵确定二次型。\n",
    "\n",
    "$对称矩阵\\Longleftrightarrow二次型矩阵\\Longleftrightarrow二次型$\n",
    "\n",
    "### 二次型矩阵性质\n",
    "* 可对角化，且特征值为实数\n",
    "* 设$\\lambda_1,\\lambda_2$是对称矩阵A的两个特征值，$\\boldsymbol{p_1}$,$\\boldsymbol{p_2}$是对应的特征向量。若$\\lambda_1\\neq \\lambda_2$,则$\\boldsymbol{p_1}$与$\\boldsymbol{p_2}$正交。\n",
    "\n",
    "### 二次标准型\n",
    "\n",
    "如果二次型只有二次项：\n",
    "$k_1x_1^2+k_2x_2^2+\\cdots+k_nx_n^2$\n",
    "则称为二次型的标准型。\n",
    "如果标准型的系数只在1,-1,0三个数中取值，也就是上式变为：\n",
    "$y_1^2+\\cdots+y_p^2-y_{p+1}^2-\\cdots-y_r^2$\n",
    "则上式为二次型的规范型。 规范型的话，也是对角阵，只是在对角线上只有1,-1,0。\n",
    "$\\color{Salmon}{注意：二次型矩阵的标准型不是唯一的,但其规范型是唯一的。}$\n",
    "\n",
    "### 合同矩阵\n",
    "设A和B是n阶矩阵，若有可逆矩阵P，使$B=P^\\mathrm{T}AP$，则称矩阵A与B合同。因为P为可逆矩阵，因此r(A)=r(B)。也就是说合同矩阵的秩相同。\n",
    "\n",
    "### 标准化\n",
    "普通二次型$\\xrightarrow{\\quad 标准化 \\quad}$标准型\n",
    "从代数上讲，对于实对称矩阵A，可以通过标准化转为对角阵：\n",
    "$\\boldsymbol{x}^\\mathrm{T}A\\boldsymbol{x}\\xrightarrow{\\quad 标准化 \\quad}\n",
    "\\boldsymbol{y}^\\mathrm{T}\\Lambda\\boldsymbol{y}$\n",
    "其中，$\\Lambda$为对角阵。\n",
    "\n",
    "### 正交标准化\n",
    "任给二次型f，总有正交变换$\\boldsymbol{x}=P\\boldsymbol{y}$，使f化为标准型：\n",
    "\n",
    "$f=\\lambda_1y_1^2+\\cdots+\\lambda_ny_n^2$\n",
    "\n",
    "其中$\\lambda_1,\\cdots,\\lambda_n$是f的矩阵A的特征值,即$\\Lambda=diag(\\lambda_1,\\cdots,\\lambda_n)=P^TAP$\n",
    "\n",
    "$P$是正交矩阵，$P=(p_1,p_2,\\cdots,p_n)$，$p_i$为对应$\\lambda_i$的单位特征向量.\n",
    "正交标准化是标准化的一种特殊情形。\n",
    "\n",
    "### 惯性定理\n",
    "设二次型$f=\\boldsymbol{x}^TA\\boldsymbol{x}$的秩为r，且有两个可逆变换：\n",
    "\n",
    "$\\boldsymbol{x}=C\\boldsymbol{y}\\quad\\boldsymbol{x}=P\\boldsymbol{z}$\n",
    "\n",
    "\n",
    "$f=k_1\\boldsymbol{y_1}^2+\\cdots+k_r\\boldsymbol{y_r}^2(k_i\\neq 0)$\n",
    "及：\n",
    "\n",
    "$f=\\lambda_1\\boldsymbol{z_1}^2+\\cdots+\\lambda_r\\boldsymbol{z_r}^2(\\lambda_i\\neq 0)$\n",
    "则$k_1,\\cdots,k_r$中正数的个数与$\\lambda_1,\\cdots,\\lambda_r$中正数的个数相等，这个定理称为惯性定理。\n",
    "若二次型f的正惯性指数为p，秩为r，则f的规范形便可确定为\n",
    "$f=y_1^2+\\cdots+y_p^2-y_{p+1}^2-\\cdots-y_r^2$\n",
    "\n",
    "### 正定二次型与负定二次型\n",
    "设二次型$f(\\boldsymbol{x})=\\boldsymbol{x}^TA\\boldsymbol{x}$\n",
    "如果对任何$\\boldsymbol{x}\\neq 0,都有f(\\boldsymbol{x}) > 0$,则称f为正定二次型,并称对称矩阵A是正定的。\n",
    "\n",
    "如果对任何$\\boldsymbol{x}\\neq 0,都有f(\\boldsymbol{x}) < 0$,则称f为负定二次型,并称对称矩阵A是负定的。\n",
    "\n",
    "赫尔维茨定理:对称矩阵A为正定$\\Longleftrightarrow$A的各阶主子式都为正"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}